#!/usr/bin/env python3
"""
安装Transformer生成器所需的依赖包
"""

import subprocess
import sys

def install_package(package_name, mirror_url="https://pypi.mirrors.ustc.edu.cn/simple/"):
    """安装指定的包"""
    try:
        subprocess.check_call([sys.executable, "-m", "pip", "install", package_name, "-i", mirror_url])
        print(f"✅ {package_name} 安装成功")
        return True
    except subprocess.CalledProcessError:
        print(f"❌ {package_name} 安装失败")
        return False

def main():
    """主安装函数"""
    packages = [
        "opencv-python",    # 视频处理
        "librosa",          # 音频处理
        "scipy",            # 科学计算
        "Pillow",           # 图像处理
        "numpy",            # 数值计算
        "torch",            # PyTorch深度学习框架
    ]
    
    print("🚀 开始安装Transformer生成器依赖包...")
    
    success_count = 0
    for package in packages:
        if install_package(package):
            success_count += 1
    
    print(f"\n📊 安装完成: {success_count}/{len(packages)} 个包安装成功")
    
    if success_count == len(packages):
        print("🎉 所有依赖包安装成功！现在可以运行Transformer生成器了。")
    else:
        print("⚠️  部分包安装失败，但基本功能仍可使用。")
        print("   图像生成器不需要额外依赖即可工作。")

if __name__ == "__main__":
    main()